<style scoped>

  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
      cursor: pointer;
  }
  /*.oitem {*/
  /*    padding: 20px;*/
  /*    background: #f2f2f2;*/
  /*    width: 640px;*/
  /*}*/
    .rj-oitem-tit {
        display: block;
        padding: 9px 20px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }
</style>
<template>
  <div class="oitem">
    <div class="rj-oitem-tit">
<!--        <span>标准{{itemNo + 1}}</span>-->
      <p id="acts" style="float: right;color: #1aad19;" @click="addItem" v-if="isLast">
        <span id="addItem" style="padding-right: 5px;">添加</span>
        <span v-if="itemNo != 0">|</span>
        <span id="delItem" style="padding-left: 5px;" @click="delItem" v-if="itemNo != 0">删除</span>
      </p>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">分级标准</label>
      <div class="layui-input-block">
        <input type="hidden" :name="'standars[' + itemNo + '].standard'" :value="currStandard.standard">
        <select class="layui-select standard" :name="'standars[' + itemNo + '].standardid'" :lay-filter="'standardid' + itemNo">
          <option value="" disabled>请选择</option>
          <option v-for="(item, index) in standards" :value="item.guid">{{item.standard}}</option>
        </select>
      </div>
    </div>
    <div class="layui-form-item" v-if="currStandard.isvaluation == 1">
      <label class="layui-form-label">单价</label>
      <div class="layui-input-block">
          <input class="layui-input price" type="number" :name="'standars[' + itemNo + '].price'" v-model="price" placeholder="请输入单价">
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ContractItem',
  data () {
    return {
      currStandard: '',
      price: '',
      showPrice: false
    }
  },
  props: [
    'itemNo',
    'isLast',
    'standards',
  ],
  mounted() {
    let that = this;
      layui.use(['form'], function () {
          var form = layui.form,
              layer = layui.layer;

          let elem = 'standardid' + that.itemNo;
          form.on(`select(${elem})`, function (data) {
              that.currStandard = that.standards.filter(item => {
                  return item.guid == data.value;
              })[0];
          })
      });

  },
  watch: {

  },
  methods: {
    addItem: function() {
      this.$emit('doAddItem');
    },
    delItem: function() {
      this.$emit('doDelItem');
    }
  }
}
</script>
